package com.fattyCorps.battle.service.battle.data;

import com.fattyCorps.battle.service.battle.behavior.Behavior;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

// 战斗中的数据
@Data
public class BattleData {
    Team left;
    Team right;

    // 获取所有表现
    public List<Behavior> getBehaviors() {
        List<Behavior> retList = new ArrayList<>();

        for (BattleHero battleHero : getAll()) {
            retList.addAll(battleHero.getBehaviors());
        }

        return retList;
    }

    public Team getPartner(BattleHero hero) {
        for (BattleHero leftHero : left.getHeroes()) {
            if (leftHero == hero) {
                return left;
            }
        }

        return right;
    }

    public Team getEnemy(BattleHero hero) {
        for (BattleHero leftHero : left.getHeroes()) {
            if (leftHero == hero) {
                return right;
            }
        }

        return left;
    }

    public List<BattleHero> getAll() {
        List<BattleHero> all = new ArrayList<>();
        all.addAll(left.getHeroes());
        all.addAll(right.getHeroes());
        return all;
    }
}
